@extends('home.parent')
@section('title','达人列表')
@section('head_js')
@endsection
@section('head_css')
<link rel="stylesheet" href="{{ asset('/css/dataTables.bootstrap.css') }}">
<link rel="stylesheet" href="{{ asset('/css/toggleButtonsMain.css') }}">
@endsection
@section('content')
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            达人列表
			<small></small>
        </h1>
        <ol class="breadcrumb">
            <li>
                <a href="{{URL('admin')}}">
                    <i class="fa fa-dashboard"></i>首页
                </a>
            </li>
            <li class="active">达人列表</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <div class="form-inline pull-right">
                            <fieldset>
                                <div class="input-group input-group-sm">
                                    <span class="input-group-addon">
                                        <strong>类型</strong>
                                    </span>
                                    <select class="form-control" id="selectedInd" style="width:150px;">
										<option value="">全部</option>
										<?if($indList){
											foreach($indList as $k=>$v){?>
												<option value="<?=$v['id'];?>"><?=$v['name']?></option>
											<?}
										}?>
                                    </select>
                                </div>
                                <div class="input-group input-group-sm">
                                    <span class="input-group-addon">
                                        <strong>是否授权</strong>
                                    </span>
                                    <select class="form-control" id="selectedAuth" style="width:150px;">
										<option value="99">全部</option>
										<option value="0">未授权</option>
										<option value="1">已授权</option>
                                    </select>
                                </div>
                                <div class="input-group input-group-sm">
                                    <span class="input-group-addon">
                                        <strong>抖音号</strong>
                                    </span>
                                    <input type="text" class="form-control" id="uid">
                                </div>
                                <div class="input-group input-group-sm">
                                    <span class="input-group-addon">
                                        <strong>昵称</strong>
                                    </span>
                                    <input type="text" class="form-control" id="name">
                                </div>
                                <div class="input-group input-group-sm">
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-primary" onclick="searchData()">
                                            <i class="fa fa-search"></i>
                                        </button>
                                    </div>
                                </div>
                            </fieldset>
                        </div>
						<div class="form-inline pull-left">
							<div class="input-group input-group-sm" style="margin-left: 20px;">
								<div class="input-group-btn" >
									<a href="#" class="btn btn-info" onclick="addTalent()" style="margin-right:20px;">新增达人</a>
									&nbsp;&nbsp;&nbsp;
									<a href="javascript:;" class="btn btn-info" onclick="warrant()">达人授权</a>
								</div>
							</div>
						</div>
                    </div>
                    <!--/.box-header-->
                    <div class="box-body">
                        <table id="data_list" class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>类型</th>
                                    <th>抖音号</th>
                                    <th>昵称</th>
                                    <th>电话</th>
                                    <th>头像</th>
                                    <th>粉丝数</th>
                                    <th>播放量</th>
                                    <th>是否授权</th>
									<th>创建人</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<div class="modal fade" id="taldataform">
	<div class="modal-dialog">
		<div class="modal-content">
		<form id="dataform">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
				<span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">新增达人</h4>
			</div>
			<div style="padding:20px;">
				<p>抖音号：<input type="text" name="tl_uid" placeholder="请输入达人抖音号" style="width:50%;"></p>
				<p>昵&nbsp;&nbsp;&nbsp;&nbsp;称：<input type="text" name="tl_uname" placeholder="请输入达人昵称" style="width:50%;"></p>
				<p>手机号：<input type="text" name="tl_tell" placeholder="请输入手机号" style="width:50%;" maxlength="11"></p>
				<p>行&nbsp;&nbsp;&nbsp;&nbsp;业：<select name="tl_type" style="width:50%;padding:3px 0;">
						<option value="">全部</option>
						<?if($indList){
							foreach($indList as $k=>$v){?>
								<option value="<?=$v['id'];?>"><?=$v['name']?></option>
							<?}
						}?>
					</select>
				</p>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" onclick="addTalentUp()">确认</button>
			</div>
		</form>
		</div>
		<!-- /.modal-content -->
	</div>
	<!-- /.modal-dialog -->
</div>
<div class="modal fade" id="warrant">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
				<span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">达人授权</h4>
			</div>
			<div style="padding:15px;">
				<label class="control-label" style="float:left;padding:8px 0 0 0;">行业：</label>
				<select class="form-control" name="tl_type" style="width:50%;float:left;">
					<option value="">全部</option>
					<?if($indList){
						foreach($indList as $k=>$v){?>
							<option value="<?=$v['id'];?>"><?=$v['name']?></option>
						<?}
					}?>
				</select>
				<div style="clear:both;"></div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" onclick="warrantUp()">确认</button>
			</div>
		</div>
	</div>
</div>
<div class="modal fade" id="upNumAll">
	<div class="modal-dialog">
		<div class="modal-content">
			<form id="xiugai">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
				<span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">某某达人</h4>
			</div>
			<div style="padding:15px;">
				<p>粉丝数：<input type="text" name="fans"></p>
				<p>播放量：<input type="text" name="play"></p>
				<p>昵&nbsp;&nbsp;&nbsp;称：&nbsp<input type="text" name="uname"></p>
				<p style="margin-left: -1px">行&nbsp;&nbsp;&nbsp;业：
					<select name="tl_type" style="width:183px;padding:4px 0;">

						<option name="tltype" value="">全部</option>
						<?if($indList){
						foreach($indList as $k=>$v){?>
						<option value="<?=$v['id'];?>"><?=$v['name']?></option>
						<?}
						}?>
					</select>

				</p>
				<input type="hidden" name="kid">
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" onclick="upNumAllUp()">确认</button>
			</div>
			</form>
		</div>

	</div>
</div>
{{--	达人视频弹窗--}}
<style>
	#tableComment table{
		border-collapse: collapse;
		color: #777;
		width:100%;
	}
	#tableComment table tr th,#tableComment table tr td{
		padding: 10px;
		border: 1px solid #f8f8f8;
		white-space: nowrap
	}
	#tableComment table tbody tr:hover{
		background:#f3f3f3;
	}
	#tableComment table thead tr{
		background: #f0f0f0;
	}
	#tableComment .more{
		text-align:center;
		padding:10px 0;
	}
	#tableComment .more span{
		cursor:pointer;
	}
</style>
<div id="tableComment" style="display:none;color:#777;padding:10px 20px 0 20px;">
	<table>
		<thead>
		<tr>
			<td>视频</td>
			<td>视频标题</td>
			<td>会员账号</td>
			<td>点赞数</td>
			<td>转发数</td>
			<td>评论数</td>
			<td>状态</td>
			<td>备注</td>
			<td>发布时间</td>
			<td>操作人</td>
		</tr>
		</thead>
		<tbody></tbody>
	</table>
	<div class="more"></div>
	<input type="hidden" name="openid">
	<input type="hidden" name="nextPage">
</div>
@endsection
@section('foot_js')
<script src="{{ asset('/js/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('/js/dataTables.bootstrap.min.js') }}"></script>
<script src="{{ asset('/js/jquery.slimscroll.min.js') }}"></script>
<script src="{{ asset('/js/fastclick.js') }}"></script>
<script src="{{ asset('/js/tools.js') }}"></script>
<script>
var list_ajax;
$(function() {
    var lang = puppet.langShow();
    list_ajax = $("#data_list").dataTable({
        language: lang,
        autoWidth: false,
        stripeClasses: ["odd", "even"],
        processing: true,
        serverSide: true,
        searching: false,
        orderMulti: false,
        order: [[0, 'desc']],
        renderer: "bootstrap",
        pagingType: "simple_numbers",
        aLengthMenu: [10, 20, 50, 100],
        iDisplayLength: 10,
        columnDefs: [{
            "targets": [1, 2, 3, 4, 5, 6, 7, 8, 9,10],
            "orderable": false
        },
        ],
        ajax: function(data, callback, settings) {
            var param = {};
            param.limit = data.length;
            param.start = data.start;
            param.page = (data.start / data.length) + 1;
            param.order = data.order;
            param.uid = $.trim($("#uid").val());
            param.name = $.trim($("#name").val());
            param.selectedInd = $.trim($("#selectedInd").val());
            param.selectedAuth = $.trim($("#selectedAuth").val());
            param.type = 1;
            $.ajax({
                type: "POST",
                url: "{{ URL('admin/talent/data/list') }}",
                cache: false,
                data: param,
                dataType: "json",
                success: function(result) {
                    var returnData = {};
                    returnData.draw = data.draw;
                    returnData.recordsTotal = result.total;
                    returnData.recordsFiltered = result.total;
                    returnData.data = result.data;
                    callback(returnData)
                }
            })
        },
        columns: [
			{"data": "tl_type"},
			{"data": "tl_uid"},
			{"data": "tl_uname"},
			{"data": "tl_tell"},
			{"data": "tl_uimg"},
			{"data": "tl_fans"},
			{"data": "tl_play"},
			{"data": "tl_auth"},
			{"data": "user_name"},
			{"data": "status"},
			{"data": "operation"},
        ],
    }).api()
});
function searchData() {
    $("#data_list").dataTable().fnDraw(false);
    layer.msg("操作成功",{icon:6});
}
function actionList(kid,status){
	switch (status) {
		case 0:
			// result = confirm("是否确认授权");
			result = layer.confirm('是否修改', {
				btn: ['确认修改', '再考虑一下'] //按钮
			}, function () {
				xiugai(kid, status);
				searchData();
			}, function () {
				location.reload();
			});
			break;
		case 1:
			result = layer.confirm('是否修改', {
				btn: ['确认修改', '再考虑一下'] //按钮
			}, function () {
				xiugai(kid, status);
				searchData();
			}, function () {
				location.reload();
			});
			break;
	}
}
function xiugai(kid,status) {
	var url = "{{ URL('admin/talent/status/update') }}";
	var data = {kid:kid,status:status};
	var result = puppet.myajax('post',url,data,false);
	if(result.code == 1){
		layer.msg(result.msg,{icon:5});
		return false;
	}else{
		layer.msg(result.msg,{icon:6});
	}
}

function deleteList(kid){
	layer.confirm('是否删除', {
		btn: ['确认删除', '再考虑一下'] //按钮
	}, function () {
		shanchu(kid);
		searchData();
	});
}function shanchu(kid) {
	var url = "{{ URL('admin/talent/status/delete') }}";
	var data = {kid:kid};
	var result = puppet.myajax('post',url,data,false);
	if(result.code == 1){
		layer.msg(result.msg,{icon:2});
		return false;
	}else{
		layer.msg(result.msg,{icon:1});
		searchData();
	}
}
//添加显示弹出层
function addTalent(){
	$('#taldataform').modal();
	$('#taldataform input[type="text"],#modal-info select').val('');
}
//新增达人
function addTalentUp(){
	var url = "{{ URL('admin/talent/data/add') }}";
	var data = $('#dataform').serialize();
	var result = puppet.myajax('post',url,data,false);
	if(result.code == 1){
		layer.msg(result.msg,{icon:5});
		return false;
	}else{
		layer.msg(result.msg,{icon:6});
		searchData();
		$('#taldataform').modal('hide');
	}
}
function warrant(){
	$('#warrant').modal();
}
function warrantUp(){
	var tl_type=$('#warrant select[name="tl_type"]').val();
	if(tl_type>0){
		window.open("{{ URL('douyin/warrant/info') }}?industry_id="+tl_type);
	}else{
		layer.msg("请选择行业",{icon:2});
	}
}
//达人数据修改
function upNumAll(kid,nickname,fans,play,type,){
	$('#upNumAll div.modal-header h4').html(nickname);
	$('#upNumAll p input[name="fans"]').val(fans);
	$('#upNumAll p input[name="play"]').val(play);
	$('#upNumAll div input[name="kid"]').val(kid);
	$('#upNumAll div input[name="uname"]').val(nickname);
	$('#upNumAll div option[name="tltype"]').val(type);
	$('#upNumAll').modal();
}
function upNumAllUp(){
	var url = "{{ URL('admin/talent/save/num') }}";
	var data = $('#xiugai').serialize();
	var result = puppet.myajax('post',url,data,false);
	if(result.code == 1){
		layer.msg(result.msg,{icon:5});
		return false;
	}else{
		layer.msg(result.msg,{icon:6});
		searchData();
		$('#upNumAll').modal('hide');
	}
}
//显示视频
function showshoucang(openid,title){
	layer.closeAll();
	getVideoComment(openid);
	$('#tableComment tbody').html("");
	$('#tableComment .more').html("");
	showlayerArea("tableComment",title,"80%","80%");
}
//拉取评论数据
function getVideoComment(openid,page=1){
	$.ajax({
		type:'POST',
		url: "{{ URL('admin/talent/list/video') }}",
		data: {openid:openid,page:page},
		dataType:'json',
		success:function(r){
			if(r.code==1){
				layer.msg(r.msg,{icon: 5});
				return false;
			}
			if(page==1){
				if(r.html==''){
					$('#tableComment tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
				}else{
					$('#tableComment tbody').html(r.html);
				}
			}else if(page>1){
				$('#tableComment tbody').append(r.html);
			}
			if(r.nextPage==0){
				$('#tableComment .more').html("");
			}else{
				$('#tableComment .more').html("<span onclick=\"getMore()\">点击加载更多</span>");
			}
			$('#tableComment input[name="openid"]').val(openid);
			$('#tableComment input[name="nextPage"]').val(r.nextPage);
		},
		error:function(){
			$('#tableComment tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
			layer.msg("网络错误",{icon: 5});
		}
	});
}
//加载下一页评论数据
function getMore(){
	var nextPage=$('#tableComment input[name="nextPage"]').val();
	var video_id=$('#tableComment input[name="videoId"]').val();
	if( nextPage!=0 && nextPage!='' && nextPage!=undefined && !isNaN(nextPage) ){
		getVideoComment(video_id,nextPage);
	}
}
</script>
@endsection